package cn.wonderland.community.service.impl;

import cn.wonderland.community.domain.Owner;
import cn.wonderland.community.dto.OwnerDto;
import cn.wonderland.community.mapper.OwnerMapper;
import cn.wonderland.community.service.IOwnerService;
import cn.wonderland.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 业主信息 服务实现类
 * </p>
 *
 * @author wonderland
 * @since 2023-05-04
 */
@Service
public class OwnerServiceImpl extends BaseServiceImpl<Owner> implements IOwnerService {

    @Autowired
    private OwnerMapper ownerMapper;


    /**
     * 入住
     * 入住成功后，修改当前业主的房屋id
     *
     * @param dto
     */
    @Override
    public void checkIn(OwnerDto dto) {
        Long ownerId = dto.getId();
        Long houseId = dto.getHouseId();

        Owner owner = new Owner();
        owner.setId(ownerId);
        owner.setHouseId(houseId);

        ownerMapper.update(owner);
    }

    @Override
    public Owner findByHouseId(Long id) {
        return ownerMapper.findByHouseId(id);
    }
}
